package com.john.blockchain.demo.mock.vo;

import com.google.gson.Gson;

import java.io.Serializable;
import java.util.List;

/**
 * 交易块信息
 *
 * @author jiangguangtao 2018/4/14
 */
public class BlockVo implements Serializable {
    private static final long serialVersionUID = -1889432518777978031L;
    private String id;
    private Long idx;

    private String hash;

    private String preHash;

    private List<TransVo> transList;

    public BlockVo() {
    }

    public BlockVo(String id, Long idx, String hash, String preHash, List<TransVo> transList) {
        this.id = id;
        this.idx = idx;
        this.hash = hash;
        this.preHash = preHash;
        this.transList = transList;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Long getIdx() {
        return idx;
    }

    public void setIdx(Long idx) {
        this.idx = idx;
    }

    public String getHash() {
        return hash;
    }

    public void setHash(String hash) {
        this.hash = hash;
    }

    public String getPreHash() {
        return preHash;
    }

    public void setPreHash(String preHash) {
        this.preHash = preHash;
    }

    public List<TransVo> getTransList() {
        return transList;
    }

    public void setTransList(List<TransVo> transList) {
        this.transList = transList;
    }

    @Override
    public String toString() {
        return "BlockVo{" +
                "id='" + id + '\'' +
                ", idx=" + idx +
                ", hash='" + hash + '\'' +
                ", preHash='" + preHash + '\'' +
                ", transList=" + transList +
                '}';
    }

    /**
     * 返回当前块的字符串代表
     *
     * @return 当前块的字符串代表
     */
    public String getBlockString() {
        return new Gson().toJson(this);
    }
}
